
import React from 'react';
import { inject, observer } from 'mobx-react';
import { WeaProgress, WeaRightMenu } from "ecCom";
import { Row, Col, Progress, Spin, Button } from 'antd';
import "./style/index.css";
import InvoiceGroup from "./InvoiceGroup";

@inject('invoiceStore')
@observer
export default class Invoice extends React.Component {
	componentDidMount() {
        const {init} = this.props.invoiceStore;
        const {refId} = this.props;
        init(refId);
    }
    
    componentWillReceiveProps(nextProps) {
        const {init} = this.props.invoiceStore;
        const {refId} = nextProps;
        if (this.props.refId !== nextProps.refId) {
			init(refId);
        }
	}
	
	componentWillUnmount(){
		const {componentWillUnmount} = this.props.invoiceStore;
		componentWillUnmount();
	}

	render() {
		const store = this.props.invoiceStore
		const {invoices} = store;

		return (
			<div style={{height:'100%',width:'100%'}}>
				{/* <WeaRightMenu datas={store.rightMenu}> */}
					<Row gutter={16}>
						{
							invoices.length>0?
							<div>
								{
									invoices.map((item)=>{
										return (<InvoiceGroup item={item} />)
									})
								}
							</div>
							:
							<div style={{textAlign:'center',color:'#ccc',paddingTop:'15px'}}>暂无数据</div>
						}
					</Row>
				{/* </WeaRightMenu> */}
			</div>
		)

	}

	// getRightMenu = ()=>{
	// 	const {canAdd,modeInfo,refId} = this.props.invoiceStore;
	// 	const fieldId = typeof(modeInfo.cons_name)=='string'?modeInfo.cons_name.substring(modeInfo.cons_name.indexOf('_')+1,modeInfo.cons_name.length):'';
	// 	return canAdd?[{
	// 		icon: <i className={"icon-coms-New-Flow"} />,
	// 		content: "新建",
	// 		key: '1',
	// 		onClick: key => window.openFullWindowHaveBar(`#/main/cube/card?type=1&modeId=${modeInfo.modeId}&formId=${modeInfo.formId}&field${fieldId}=${refId}`),
	// 	}]:[]
	// }

}